package com.zhiyou100.servlet.management.student;

import com.zhiyou100.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description TODO 根据 sid 删除一个
 * @packageName ${PACKAGE_NAME}
 * @ClassName ${NAME}
 * @Author yang
 * @Date 8/13/20 10:14
 * @Version V1.0
 */
@WebServlet(name = "DelOneBySid", urlPatterns = "/management/student/DelOneBySid")
public class DelOneBySid extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try (StudentService studentService = new StudentService()) {
            final String sid = request.getParameter("sid");
            studentService.delOneBySid(sid);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
